 <%@ page language="java" contentType="text/json; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="java.util.*, java.net.*, java.io.* "%>
<%
    // we simply pass the search reqest on to Solr
    // we assume Solr is running on the same server and on port 8480
    // for search we find layers that are in the extent or layers that cover the extent
    // we also do a wildcard search based on the passed keyword in several fields
    // boost is applied to layers within the extent and keyword matches 
    // there is also a function that adds to the score based on 

    final String asterik = "%2a";
	final String openParen = "%28";
	final String closeParen = "%29";
	final String openBracket = "%5B";
	final String closeBracket = "%5D";
	final String colon = "%3a";
	final String tilde = "%7e";
	final String comma = "%2c";
	final String space = "%20";
		
    String wmsLocation = request.getParameter("url");
    String layerName = request.getParameter("layername");
    String xCoord = request.getParameter("x");
    String yCoord = request.getParameter("y");
    String bbox = request.getParameter("bbox");
    String height = request.getParameter("height");
    String width = request.getParameter("width");
    String format = "application/vnd.ogc.gml";
    //format = "text/html";
	String url$ = wmsLocation + "?service=wms&version=1.1.1&request=GetFeatureInfo&info_format=" + format + "&SRS=EPSG:900913&feature_count=1&styles=&height=" + height + "&width=" + width +"&bbox=" + bbox + "&x=" + xCoord + "&y=" + yCoord +"&query_layers=" + layerName + "&layers=" + layerName;

	System.out.println(" in getFeatureInformation, url = " + url$);
	URL url = new URL(url$);
	InputStream inputStream = url.openStream();
	InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
	BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
	String currentLine = bufferedReader.readLine();
	String html = "";
	while (currentLine != null)
	{
		currentLine = currentLine.replaceAll("\\n|\\r", " ");
		html = html + currentLine;
		System.out.println(currentLine);	
		currentLine = bufferedReader.readLine();
		
	}
	String json = html;
	
	out.write(json);
%>
